{% extends "base.html" %}

{% block head %}
  <script type="text/javascript">
  function checkForm(theForm) {
    var filePath = theForm.file.value;
    if (filePath == '') {
      alert('上传文件不能为空！');
      return false;
    }
    theForm.submitButton.disabled = true;
    theForm.submitButton.value = "上传中，请稍候......";
    theForm.fileName.value = filePath.substr(filePath.lastIndexOf('\\') + 1);
    return true;
  }

  </script>
{% endblock %}

{% block body %}
    <form action="/upload" method="post" enctype="multipart/form-data" onSubmit="return checkForm(this)">
      <input type="hidden" name="fileName"/>
      <div>上传文件(受GAE限制，最大只能1M哦)：</div>
      <div><input type="file" name="file" size="40"/></div>
      <div><p><input name="submitButton" type="submit" value=" 上 传 "/></p></div>
      <div>上传文件历史记录：</div>
      {% if files %}
          <table width="100%" border="1">
              <tr>
                  <td>文件名</td>
                  <td>上传时间</td>
                  <td>文件大小</td>
                  <td>来源IP</td>
              </tr>
            {% for file in files %}
              <tr>
                  <td align="left"><a href="/download?key={{file.key}}">{{file.name}}</a></td>
                  <td align="center">{{file.gmtCreate|date:"Y-m-d H:i:s"}}</td>
                  <td align="right">{{ file.size|filesizeformat }}</td>
                  <td align="center">{{file.sourceIp}}</td>
              </tr>
            {% endfor %}
          </table>
      {% endif %}
    </form>
{% endblock %}
